package com.zz.tijian.entity.doc;


import com.zz.tijian.entity.Hospital;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class HospitalDoc {
    /**
     * 医院编号
     */
    private Integer hpId;

    /**
     * 医院名称
     */
    private String name;

    /**
     * 医院图片
     */
    private String picture;

    /**
     * 医院电话
     */
    private String telephone;

    /**
     * 医院地址
     */
    private String address;

    /**
     * 营业时间
     */
    private String businessHours;

    private String startTime;
    private String endTime;

    /**
     * 采血截止时间
     */
    private String deadline;
    private String deadlineTime;

    /**
     * 预约人数规则
     */
    private String rule;

    /**
     * 医院状态（1：正常；2：其他）
     */
    private Integer state;



    public HospitalDoc(Hospital hospital){
        this.hpId = hospital.getHpId();
        this.name = hospital.getName();
        this.picture = hospital.getPicture();
        this.telephone = hospital.getTelephone();
        this.address = hospital.getAddress();
        this.businessHours = hospital.getBusinessHours();
        String[] s1 = hospital.getBusinessHours().split(" ");
        String[] s = s1[1].split("-");
        if(s[0].length()==4){
            s[0]="0"+s[0];
        }
        this.startTime = s[0];
        if(s[1].length()==4){
            s[1]="0"+s[1];
        }
        this.endTime = s[1];
        this.deadline=hospital.getDeadline();
        String[] s2 = hospital.getDeadline().split(" ");
        if(s2[1].length()==4){
            s2[1]="0"+s2[1];
        }
        this.deadlineTime = s2[1];
        this.rule = hospital.getRule();
        this.state = hospital.getState();
    }
}
